package entities {
	
	import entities.Abilities;
	
	import org.flixel.FlxG;
	import org.flixel.FlxSprite;
	import org.flixel.plugin.photonstorm.FlxBar;
	import org.flixel.plugin.photonstorm.FlxDelay;
	import org.flixel.plugin.photonstorm.FlxMath;
	
	public class Boss extends Enemy {
		
		private var healthBar:FlxBar;
		private var _timer:Number = 0;	// delaying attacks
		
		public function Boss(X:int, Y:int, infos:Object) {
			super(X, Y, infos);
			healthBar = new FlxBar(0, 0, 1, width, 3, this, 'health', 0, infos.gamePlay.health, true);
			Registry.dynamicPool.add(healthBar);
			healthBar.trackParent(0, -5);
			//trace(_tracking);
		}
		
		//private var onscreen:Boolean;
		
		override public function update():void {
			super.update();
			_timer += FlxG.elapsed;
			if(onScreen() ){
				if(abilities.allowed){
					if ( _timer >= coolDown && !_attacking) {	//cooldown is over
						abilities.randomAttack();
						_timer = 0;
					} 
				}
			}
		}
		
	
		override public function kill():void {
			super.kill();
			if(Registry.player) {Registry.player.levelUp();	}
			Registry.fx.particles(this, 0x00991111, 30, 1);
			Registry.dynamicPool.remove(healthBar,true);
			healthBar = null;
		}
	

	}
}
